package cn.hdu.liang.enumerated;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.TreeSet;


enum Explore {HERE, THERE}

public class Reflection {
    public static Set<String> analyze(Class<?> enumClass) {
        System.out.println("----- 分析 " + enumClass + " -----");
        System.out.println("接口:");
        for(Type t : enumClass.getGenericInterfaces()) {
            System.out.println(t);
        }
        System.out.println("基类: " + enumClass.getSuperclass());
        System.out.println("方法: ");
        Set<String> methods = new TreeSet<>();
        for(Method m : enumClass.getMethods()) {
            methods.add(m.getName());
        }
        System.out.println(methods);
        return methods;
    }

    public static void main(String[] args) {
        Set<String> exploreMethods = analyze(Explore.class);
        Set<String> enumMethods = analyze(Enum.class);

        System.out.println("Explore.containsAll(Enum)? " + exploreMethods.containsAll(enumMethods));
        System.out.print("Explore.removeAll(Enum): ");
        exploreMethods.removeAll(enumMethods);

        System.out.println(exploreMethods);

        //OSExecute.command("javap cn.hdu.liang.enumerated.Explore");
    }
}
